<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('任务详情')" />
</head>
<body>
	<section class="content">
	    <form class="form-horizontal" id="sysJobDetailForm">
	        <input class="hidden" name="jobId" th:value="${sysJob.jobId}">
	        <div class="box-body">
	            <div class="form-group">
	                <label class="col-sm-2 control-label">任务名称 :</label>
	                <div class="col-sm-9">
	                    <input type="text" class="form-control" th:value="${sysJob.jobName}" name="jobName" required placeholder="请输入任务名称">
	                </div>
	            </div>
	            <div class="form-group">
		            <label  class="col-sm-2 control-label">任务分组 :</label>
		            <div class="col-sm-9">
		                <select name="jobGroup" class="form-control" required>
		                    <option th:selected="${sysJob.jobGroup == 'DEFAULT'}" value="DEFAULT">默认</option>
		                    <option th:selected="${sysJob.jobGroup == 'SYSTEM'}" value="SYSTEM">系统</option>
		                </select>
		            </div>
	            </div>
	            <div class="form-group">
	                <label class="col-sm-2 control-label">调用字符串 :</label>
	                <div class="col-sm-9">
	                    <input type="text" class="form-control" th:value="${sysJob.invokeTarget}" name="invokeTarget" required placeholder="请输入调用目标">
	                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> Bean调用示例：jobTaskTest.jobNoParams()</span>
	                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> Class类调用示例：com.cong.modules.job.task.cancelOrder.cancel('取消操作')</span>
	                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 参数说明：支持字符串，布尔类型，长整型，浮点型，整型</span>
	                </div>
	            </div>
	            <div class="form-group">
	                <label class="col-sm-2 control-label">cron表达式 :</label>
	                <div class="col-sm-9">
	                    <input type="text" class="form-control" th:value="${sysJob.cronExpression}" name="cronExpression" placeholder="请输入cron表达式" required>
	                    <a href="javascript:void(0);" onclick="openCron()"><i class="fa fa-star"></i>查看cron表达式<i class="fa fa-star"></i></a>
	                </div>
	            </div>
	            <div class="form-group">
	                 <label class="col-sm-2 control-label">执行策略 :</label>
	                 <div class="col-sm-9">
	                     <label class="radio-inline pr-5"><input type="radio" th:field="*{sysJob.misfirePolicy}" name="misfirePolicy" value="0" checked="checked" required> 立刻执行</label>
	                     <label class="radio-inline pr-5"><input type="radio" th:field="*{sysJob.misfirePolicy}" name="misfirePolicy" value="1" required> 执行一次</label>
	                     <label class="radio-inline pr-5"><input type="radio" th:field="*{sysJob.misfirePolicy}" name="misfirePolicy" value="2" required> 放弃执行</label>
	                     <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 立刻执行：重做错过的所有频率周期后</span>
	                     <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 执行一次：以当前时间为触发频率立刻触发一次执行</span>
	                     <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 放弃执行：不触发立即执行</span>
	                 </div>
	             </div>
	             <div class="form-group">
	                 <label class="col-sm-2 control-label">并发执行 :</label>
	                 <div class="col-sm-9">
	                     <label class="radio-inline pr-5"><input type="radio" th:field="*{sysJob.concurrent}" name="concurrent" value="0" checked="checked" required> 允许</label>
	                     <label class="radio-inline pr-5"><input type="radio" th:field="*{sysJob.concurrent}" name="concurrent" value="1" required> 禁止</label>
	                 </div>
	             </div>
	             <div class="form-group">
	                 <label class="col-sm-2 control-label">运行状态 :</label>
	                 <div class="col-sm-9">
	                     <label class="radio-inline pr-5"><input type="radio" th:field="*{sysJob.status}" name="status" value="0" checked="checked" required> 正常</label>
	                     <label class="radio-inline pr-5"><input type="radio" th:field="*{sysJob.status}" name="status" value="1" required> 暂停</label>
	                 </div>
	             </div>
	             <div class="form-group">
	                <label class="col-sm-2 control-label">备注描述 :</label>
	                <div class="col-sm-9">
	                    <input type="text" class="form-control" th:value="${sysJob.remark}" name="remark" required placeholder="请输入备注">
	                </div>
	             </div>
	        </div>
	    </form>
    </section>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
    /* 查看cron表达式 */
	function openCron(){
		parent.layer.open({
			type : 2,
			title : 'cron表达式',
			closeBtn : 1,
			anim: -1,
			isOutAnim: false,
			shadeClose : true,
			shade : 0.3,
			area : ['100%', '100%'],
			btn : ['取消'],
			content : ctx + 'sysJob/tocron',
			success: function(layero, index){
			}
		});
	}
	function submitHandler () {
		if($("#sysJobDetailForm").validate().form()){
			$.common.postAjax(
				ctx + "sysJob/editSysJob",
				$("#sysJobDetailForm").serialize(),
				function (data) {
					if (data.code == 0) {
						parent.layer.closeAll('iframe'); // 关闭当前frame
						var topWindow = $(window.parent.document);
						var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id');
						var topWindow = $('.J_iframe[data-id="' + currentId + '"]', topWindow)[0];
						if (!$.common.isEmpty(topWindow) && !$.common.isEmpty(currentId)) {
							var $contentWindow = topWindow.contentWindow;
							$contentWindow.$(".layui-layer-padding").removeAttr("style");
							$contentWindow.$.table.refreshTable();
							$contentWindow.toastr.success(data.msg);
						} else {
							toastr.error(data.msg);
						}
					} else {
						toastr.error(data.msg);
					}
				}
			)
		}
	}
	</script>
</body>
</html>